package com.chatmcp.mcprouter.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * 服务器类型配置
 * 根据mcp.server.type属性决定启动哪种服务器
 */
@Configuration
public class ServerTypeConfig {

    /**
     * 代理服务器配置
     * 当mcp.server.type=proxy或未设置时激活
     */
    @Configuration
    @ConditionalOnProperty(name = "mcp.server.type", havingValue = "proxy", matchIfMissing = true)
    public static class ProxyServerConfig {
        
        @Bean
        public String serverType(Environment env) {
            String port = env.getProperty("server.port", "8025");
            System.out.println("启动代理服务器，端口: " + port);
            return "proxy";
        }
    }
    
    /**
     * API服务器配置
     * 当mcp.server.type=api时激活
     */
    @Configuration
    @ConditionalOnProperty(name = "mcp.server.type", havingValue = "api")
    public static class ApiServerConfig {
        
        @Bean
        public String serverType(Environment env) {
            String port = env.getProperty("server.port", "8027");
            System.out.println("启动API服务器，端口: " + port);
            return "api";
        }
    }
} 